openapi: 3.0.1
info:
  title: PlatformV API for SmartMarket API
  description: PlatformV API for SmartMarket MVP documentation
  license:
    name: Commercial
  version: 0.1.0
tags:
- name: Platform V component
  description: Platform V components API
paths:
  /resources:
    post:
      summary: Create resource
      operationId: createResource
      tags:
      - Platform V component
      requestBody:
        description: Resource definition
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResourceCreateDto'
        required: true
      responses:
        201:
          description: Resource is created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResourceDto'
        400:
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
        500:
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
      x-codegen-request-body-name: body
  /resources/{resource-name}:
    parameters:
    - name: resource-name
      in: path
      required: true
      schema:
        $ref: "#/components/schemas/ResourceName"
    get:
      summary: Get resource
      description: Get resource by ID
      operationId: getResourceById
      tags:
      - Platform V component
      responses:
        200:
          description: Resource object
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResourceDto'
        404:
          description: Resource not found
          content: {}
        500:
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
    delete:
      summary: Delete resource
      description: Delete resource with specified ID
      operationId: deleteResourceById
      tags:
      - Platform V component
      responses:
        200:
          description: Resource object
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResourceDto'
        404:
          description: Resource not found
          content: {}
        500:
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
    put:
      summary: Update resource by ID
      description: Update resource with specified ID
      operationId: updateResourceById
      tags:
      - Platform V component
      requestBody:
        description: New resource state
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ResourceUpdateDto"
      responses:
        200:
          description: Successfully updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ResourceDto"
        400:
          description: Wrong input data
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorDto"
        404:
          description: Resource not found
        500:
          description: Failed to update
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorDto"
  /search-resources:
    post:
      operationId: searchResources
      tags:
      - Platform V component
      requestBody:
        description: Search request object, filters, paging
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SearchRequestDto'
        required: true
      responses:
        202:
          description: Accepted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResponseDto'
        400:
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
        500:
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDto'
      x-codegen-request-body-name: body
components:
  schemas:
    ResourceName:
      type: string
      description: сквозной идентификатор ресурса согласно стандарту STD-8
      example:
      - rn:pvc:v8s:az1:123:456:789
      - rn:pvc:s-up:az1:123:456:789
    ResourceCreateDto:
      required:
      - name
      type: object
      properties:
        name:
          $ref: "#/components/schemas/ResourceName"
        properties:
          type: object
          properties: {}
          description: "Resource specific properties for a specific service.\n Functions,\
            \ required properties: \n function_template(since 20-Apr-2021): nodejs14-graphql\
            \ | python38-graphql \n Functions, optional properties: \n dataspace_id:\
            \ ds_id"
          example:
            function_template: nodejs12
            dataspace_id: "6942468495208415233"
    ResourceUpdateDto:
      required:
      - properties
      type: object
      properties:
        properties:
          type: object
          properties: { }
          description: "Resource specific properties for a specific service.\n Functions,\
                \ required properties: \n function_template(since 20-Apr-2021): nodejs14-graphql\
                \ | python38-graphql \n Functions, optional properties: \n dataspace_id:\
                \ ds_id"
          example:
            function_template: nodejs12
            dataspace_id: "6942468495208415233"
    ResourceDto:
      required:
      - name
      - state
      type: object
      properties:
        name:
          $ref: "#/components/schemas/ResourceName"
        state:
          $ref: "#/components/schemas/ResourceStateDto"
        endpoints:
          type: array
          description: Resource instance endpoints
          items:
            $ref: '#/components/schemas/EndpointDto'
        created:
          type: string
          description: timestamp when resource was created
          format: date-time
        updated:
          type: string
          description: timestamp when resource was modified last time
          format: date-time
        properties:
          type: object
          properties: { }
          description: Resource specific properties
          example:
            function_template: nodejs12
            foo: bar
    ResourceStateDto:
      type: object
      required:
      - value
      properties:
        value:
          type: string
          description: Resource state "DRAFT", "PROVISIONING", "READY", "ERROR", "TERMINATING",
            "DELETED"
        reason:
          $ref: "#/components/schemas/ResourceStateReasonDto"
    ResourceStateReasonDto:
      type: object
      required:
      - code
      properties:
        code:
          type: string
          description: Resource state code
          example: FCN:1234
        description:
          type: string
          description: Resource state description
    SearchRequestDto:
      type: object
      properties:
        resource-names:
          type: array
          description: List of resource names
          example:
          - rn:..
          - rn:..
          items:
            $ref: "#/components/schemas/ResourceName"
        updated_from:
          type: string
          description: Lower bound for 'updated' field.
          format: date-time
        limit:
          type: integer
          description: Maximum number of items on response
    SearchResponseDto:
      type: object
      properties:
        size:
          type: integer
          description: number of elements in "items" array
          example: 100
        has_more:
          type: boolean
          description: flag that there are more elements, and next page should be
            requested
          example: false
        items:
          type: array
          description: List of resources. Resources are sorted by 'updated' field
            (ASCENDING)
          items:
            $ref: '#/components/schemas/ResourceDto'
    EndpointDto:
      type: object
      properties:
        url:
          type: string
          description: Endpoint URL
          example: https://sampleurl.tld/functions/xxxx
        type:
          type: string
          description: Endpoint URL Type (graphql, graphiql, rest)
          example: graphql
        description:
          type: string
          description: Human readable description
    CredentialsDto:
      type: object
      properties:
        access_key:
          type: string
          description: access key, which must have access to endpoint
          example: randOmACce33Key
        secret_key:
          type: string
          description: access key, which must have access to endpoint
          example: randOmsEcrEtKey
    DropAppUpdatePropertiesDto:
      type: object
      properties:
        suspend:
          type: boolean
          description: flag indicating of requested action onto component (suspend/resume)
    DropAppCreatePropertiesDto:
      type: object
      properties:
        compose_yml:
          $ref: "#/components/schemas/DropAppComposeYaml"
    DropAppComposeYaml:
      type: string
      description: Compose yml provided by user/system
      example: >-
        version: 3.0.0
        services:
          service-1:
            image: random-image-name
    ErrorDto:
      required:
      - code
      - message
      type: object
      properties:
        code:
          type: string
          description: Error code
        message:
          type: string
          description: Error message
        details:
          type: array
          description: Error details as array of arbitrary objects for automated processing
          example:
          - type: error_doc_link
            errorURL: https://sampleurl.tld/docs/error-codes/123
          - type: localized_message
            localizedErrorMessage: Некорректное значение {} параметра {}
            params:
            - xxx
            - limit
          items:
            type: object
            properties: {}
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic